package com.bw.controller;

import com.bw.bean.Trafficbean;
import com.bw.service.TrafficService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLOutput;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @projectName: SpringBoot1
 * @fileName: TrafficController
 * @packageName: com.bw.controller
 * @date: 2025/9/18 10:15
 * @author: ymw
 */
@RestController
public class TrafficController {
   @Autowired
   TrafficService trafficService;
   @RequestMapping("traffic")
    public List<Trafficbean> traffic(@RequestParam (defaultValue = "0") int d){
       if (d == 0) {
           Date date = new Date();
           SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
           d = Integer.parseInt(yyyyMMdd.format(date));
       }
      List<Trafficbean> traffic = trafficService.traffic(d);
      System.out.println(d);
       return traffic;
   }
}
